"""
逆序删除，正序会越界，del元素之后len(nums)会变小
"""
def removeDuplicates(nums):
    for i in range(len(nums) - 1, 0, -1):
        if nums[i] == nums[i - 1]:
            del nums[i]
    return len(nums)


if __name__ == '__main__':
    nums = [0, 0, 1, 1, 2, 2, 3, 3, 3]
    print(removeDuplicates(nums))
